﻿using Shumei.EFCore.SimpleService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace source.Controllers
{
    /// <summary>
    /// 在线视频课程
    /// </summary>
    public class CourseController:Controller
    {
        private CourseService courseService;
        public CourseController()
        {
            courseService = new CourseService();
        }
        public ActionResult Index()
        {
            return RedirectToAction("CourseAll");
        }
        public ActionResult Course(int CourseId)
        {
            var CourseModel = courseService.Find(CourseId);
            if(CourseModel == null)
            {
                RedirectToAction("CourseAll");
                
            }
            return View(CourseModel);
        }
        public ActionResult CourseAll()
        {
            var courseList = courseService.List();
            return View(courseList);
        }
        public ActionResult CourseAll_Sort()
        {
            return View();
        }
        public ActionResult CourseAll_Search()
        {
            return View();
        }

        public ActionResult CourseVideo(int CourseId,int VideoId)
        {
            var courseModel = courseService.Find(CourseId);
            ViewData["Course"] = courseModel;
            if(courseModel == null)
            {

            }
            var courseVideo = courseModel.CourseVideos.Find(x => x.Id == VideoId);
            if (courseVideo == null)
            {

            }
            return View(courseVideo);
        }
    }
}